<div id="main" class="col-left">
	<h1 class="page-title">All Products</h1>
	<ul class="products">
<?php if (!empty($model)) :
		$count = 0;
		foreach ($model as $key=>$item):

			if ((($key+1) % 3) == 0) {
				$count = 0;
				$cls = "last";
			} else {
				if ($count == 0) {
					$cls = "first";
				} else {
					$cls ="";
				}
			}
			$count ++;
			
			$path = "upload_files/products";
			$thumb = "169-270";
			
			$folder_dir = Yii::getPathOfAlias('webroot')."/wwwroot/{$path}/{$item->image}";
			
			if (!is_file($folder_dir)) {
				$src = Yii::app()->baseUrl."/uploads/no-image.png";
			} else {
				$src = Yii::app()->baseUrl."/wwwroot/{$path}/{$item->image}";
			}
?>
		<li class="product <?php echo $cls;?>">
			<a href="<?php echo Yii::app()->createUrl('/products/public', array('alias' => $item->alias))?>">
				<span class="onsale">Sale!</span>	
				<img src="<?php echo $src?>" class="attachment-shop_catalog wp-post-image" alt="<?php echo $item->name?>" />
				<h3><?php echo $item->name;?></h3>
				<span class="price"><span class="from">From: </span><del><span class="amount">&#36;25</span></del> <ins><span class="amount">&#36;12.50</span></ins></span>
			</a>
			<a href="<?php echo Yii::app()->createUrl('/products/public', array('alias' => $item->alias))?>" data-product_id="125" class="button add_to_cart_button product_type_variable">Select options <?php //echo $item->price;?></a>			
		</li>
	<?php endforeach;?>
<?php endif;?>
	</ul>
	<div class="wd-cls-container-paging">
		<?php 
			$this->widget('CLinkPager', array(
				'currentPage'=>$pages->getCurrentPage(),
				'itemCount'=>$item_count,
				'pageSize'=>$page_size,
				'maxButtonCount'=>5,
				'firstPageLabel' => 'First',
				'prevPageLabel' => '..',
				'nextPageLabel' => '..',
				'lastPageLabel' => 'Last',
				'header'=>'',
				'htmlOptions'=>array('class'=>'wd-paging'),
			));
			
		?>
	</div>
	<div class="clear"></div>
	<form class="woocommerce_ordering" method="POST">
		<select name="sort" class="orderby">
			<option value="abc"  <?php echo ($sort == null || $sort == "abc") ? "selected='selected'" : "";?>>Alphabetically</option>
			<option value="date" <?php echo ($sort == "date") ? "selected='selected'" : "";?>>Most Recent</option>
			<option value="price" <?php echo ($sort == "price") ? "selected='selected'" : "";?>>Price</option>
		</select>
		<script>
		$().ready(function(e){
			<?php
			if($category == null){
			?>
			$(".orderby").live('change',function(e){
				window.location.href = "<?php echo Yii::app()->createUrl('/boutique');?>?sort="+$(this).val();
			});
			<?php
			}else{
			?>
			$(".orderby").live('change',function(e){
				window.location.href = "<?php echo Yii::app()->createUrl('/boutique?category='.$category);?>&sort="+$(this).val();
			});
			
			<?php
			}
			?>
			
		});
		</script>
	</form>
</div>

<div id="sidebar" class="col-right">
	<?php 
		$this->widget('widgets.featured-products.FeaturedProducts', array(
		));
	?>
</div>